import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/utils/vant-import'
import 'amfe-flexible'

Vue.config.productionTip = false

const list = ['add', 'mine', 'addCollectData']
router.beforeEach((to, from, next) => {
  if (!store.state.username && list.includes(to.name)) {
    router.push({
      name: 'login',
      params: {
        name: from.name,
      },
    })
    return
  }
  next()
})

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
